#include<iostream>
#include<sys/types.h>
#include<unistd.h>
#include<sys/wait.h>
using namespace std;


int main()
{
    pid_t id=fork();
    if(!id)
    {
        char* const argv[]
        {
           (char*) "ls",
           (char*) "--color",
           (char*) "-a",
           (char*) "-l",
            nullptr
        };
        execv("/usr/bin/ls",argv);
        exit(1);
    }
    pid_t pid=waitpid(id,nullptr,0);
    if(pid>0)
    {
        cout<<"等待子进程成功！"<<endl;
    }


    return 0;
}

